<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=, initial-scale=1.0">
    <title>上课例子</title>
</head>

<body>

    <span id="showtime"></span>
    <script>
        let mytimer = function () {
            let d = new Date(); //获得系统当前日期时间
            document.getElementById("showtime").innerHTML =
                d.toLocaleString();
        };
        setInterval(mytimer, 1000);
    </script> -->

     <h2>剩余时间：<span id="clock">5</span> 秒</h2>
    <script>
        let t = 5;
        let x = document.getElementById("clock");

        let id =setInterval (function fun() {
            t--;
            x.innerHTML = t;
            if (t <= 0) {
                clearInterval(id);
                window.location = "http://www.wust.edu.cn";
            }
        },1000);s
    </script>


    <script>
        let myjsonObj = {
            "name": "网站",
            "num": 3,
            "sites": [{
                    "name": "Google",
                    "info": ["Android", "Google搜索", "Google翻译"]
                },
                {
                    "name": "Tencent",
                    "info": ["QQ", "微信", "网游"]
                },
                {
                    "name": "Taobao",
                    "info": ["淘宝", "天猫"]
                }
            ]
        }

        for (let i = 0; i < myjsonObj.sites.length; i++)
            for (let j = 0; j < myjsonObj.sites[i].info.length; j++) {
                document.write(myjsonObj.sites[i].name + ":")
                document.write(myjsonObj.sites[i].info[j] + "<br>");
            }
    </script> -->


    <div id="show"></div>
    <script src="weather.js"></script>
    <script>
        let show = document.getElementById("show");
        show.innerHTML = "未来5天12点气温：<br>";
        let list = weather.list; // list字段存放天气信息，该值为json数组
        for (let i = 0; i < list.length; i++) {
            let d = new Date(list[i].dt_txt); // dt_txt字段存放的是期时间串
            if (d.getHours() == 12) {
                let temp = list[i].main.temp - 273.15; //temp为K氏温度值，转为摄氏度
                show.innerHTML +=
                    d.toLocaleDateString() + " 12:00温度：" + temp.toFixed(2) + "<br>";
            }
        }
    </script>
</body>

</html>